package com.ybb.vue.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ybb.vue.common.Result;
import com.ybb.vue.entity.OperationRecords;
import com.ybb.vue.service.OperationRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ybb
 * @version 1.0
 * @Description 操作记录
 * @Date 2023/3/30 16:28
 */

@RestController
@RequestMapping("/operationRecords")
public class OperationRecordsController {

    @Autowired
    private OperationRecordsService operationRecordsService;

    @GetMapping("/operationRecordsList")
//    @PreAuthorize("hasAuthority('alarm:management:list')"+"||"+"hasAuthority('alarm:management:nquery')")
    public Result<?> operationRecordsList (@RequestParam(defaultValue = "1") Integer pageNum,
                                     @RequestParam(defaultValue = "10") Integer pageSize) {
        LambdaQueryWrapper<OperationRecords> queryWrapper = Wrappers.<OperationRecords>lambdaQuery();
        queryWrapper.orderByDesc(OperationRecords::getCreateTime);
        Page<OperationRecords> result = operationRecordsService.page(new Page<>(pageNum, pageSize),queryWrapper);
        return Result.success(result);
    }
}
